﻿
   // using ChainStock.Properties;
    using System;
    using System.CodeDom.Compiler;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Threading;
    using System.Web.Services;
    using System.Web.Services.Description;
    using System.Web.Services.Protocols;

    [DebuggerStepThrough, WebServiceBinding(Name="SmsServiceSoap", Namespace="http://tempuri.org/"), GeneratedCode("System.Web.Services", "4.0.30319.1"), DesignerCategory("code")]
    public partial class SmsService : SoapHttpClientProtocol
    {
        private GetBalanceCompletedEventHandler _GetBalanceCompleted;
        private SendOrPostCallback _GetBalanceOperationCompleted;
        private RegisterExCompletedEventHandler _RegisterExCompleted;
        private SendOrPostCallback _RegisterExOperationCompleted;
        private RegisterZsCompletedEventHandler _RegisterZsCompleted;
        private SendOrPostCallback _RegisterZsOperationCompleted;
        private SendMessageCompletedEventHandler _SendMessageCompleted;
        private SendOrPostCallback _SendMessageOperationCompleted;
        private bool useDefaultCredentialsSetExplicitly;

        public event GetBalanceCompletedEventHandler GetBalanceCompleted
        {
            add
            {
                GetBalanceCompletedEventHandler handler2;
                GetBalanceCompletedEventHandler getBalanceCompleted = this._GetBalanceCompleted;
                do
                {
                    handler2 = getBalanceCompleted;
                    GetBalanceCompletedEventHandler handler3 = (GetBalanceCompletedEventHandler) Delegate.Combine(handler2, value);
                    getBalanceCompleted = Interlocked.CompareExchange<GetBalanceCompletedEventHandler>(ref this._GetBalanceCompleted, handler3, handler2);
                }
                while (getBalanceCompleted != handler2);
            }
            remove
            {
                GetBalanceCompletedEventHandler handler2;
                GetBalanceCompletedEventHandler getBalanceCompleted = this._GetBalanceCompleted;
                do
                {
                    handler2 = getBalanceCompleted;
                    GetBalanceCompletedEventHandler handler3 = (GetBalanceCompletedEventHandler) Delegate.Remove(handler2, value);
                    getBalanceCompleted = Interlocked.CompareExchange<GetBalanceCompletedEventHandler>(ref this._GetBalanceCompleted, handler3, handler2);
                }
                while (getBalanceCompleted != handler2);
            }
        }

        public event RegisterExCompletedEventHandler RegisterExCompleted
        {
            add
            {
                RegisterExCompletedEventHandler handler2;
                RegisterExCompletedEventHandler registerExCompleted = this._RegisterExCompleted;
                do
                {
                    handler2 = registerExCompleted;
                    RegisterExCompletedEventHandler handler3 = (RegisterExCompletedEventHandler) Delegate.Combine(handler2, value);
                    registerExCompleted = Interlocked.CompareExchange<RegisterExCompletedEventHandler>(ref this._RegisterExCompleted, handler3, handler2);
                }
                while (registerExCompleted != handler2);
            }
            remove
            {
                RegisterExCompletedEventHandler handler2;
                RegisterExCompletedEventHandler registerExCompleted = this._RegisterExCompleted;
                do
                {
                    handler2 = registerExCompleted;
                    RegisterExCompletedEventHandler handler3 = (RegisterExCompletedEventHandler) Delegate.Remove(handler2, value);
                    registerExCompleted = Interlocked.CompareExchange<RegisterExCompletedEventHandler>(ref this._RegisterExCompleted, handler3, handler2);
                }
                while (registerExCompleted != handler2);
            }
        }

        public event RegisterZsCompletedEventHandler RegisterZsCompleted
        {
            add
            {
                RegisterZsCompletedEventHandler handler2;
                RegisterZsCompletedEventHandler registerZsCompleted = this._RegisterZsCompleted;
                do
                {
                    handler2 = registerZsCompleted;
                    RegisterZsCompletedEventHandler handler3 = (RegisterZsCompletedEventHandler) Delegate.Combine(handler2, value);
                    registerZsCompleted = Interlocked.CompareExchange<RegisterZsCompletedEventHandler>(ref this._RegisterZsCompleted, handler3, handler2);
                }
                while (registerZsCompleted != handler2);
            }
            remove
            {
                RegisterZsCompletedEventHandler handler2;
                RegisterZsCompletedEventHandler registerZsCompleted = this._RegisterZsCompleted;
                do
                {
                    handler2 = registerZsCompleted;
                    RegisterZsCompletedEventHandler handler3 = (RegisterZsCompletedEventHandler) Delegate.Remove(handler2, value);
                    registerZsCompleted = Interlocked.CompareExchange<RegisterZsCompletedEventHandler>(ref this._RegisterZsCompleted, handler3, handler2);
                }
                while (registerZsCompleted != handler2);
            }
        }

        public event SendMessageCompletedEventHandler SendMessageCompleted
        {
            add
            {
                SendMessageCompletedEventHandler handler2;
                SendMessageCompletedEventHandler sendMessageCompleted = this._SendMessageCompleted;
                do
                {
                    handler2 = sendMessageCompleted;
                    SendMessageCompletedEventHandler handler3 = (SendMessageCompletedEventHandler) Delegate.Combine(handler2, value);
                    sendMessageCompleted = Interlocked.CompareExchange<SendMessageCompletedEventHandler>(ref this._SendMessageCompleted, handler3, handler2);
                }
                while (sendMessageCompleted != handler2);
            }
            remove
            {
                SendMessageCompletedEventHandler handler2;
                SendMessageCompletedEventHandler sendMessageCompleted = this._SendMessageCompleted;
                do
                {
                    handler2 = sendMessageCompleted;
                    SendMessageCompletedEventHandler handler3 = (SendMessageCompletedEventHandler) Delegate.Remove(handler2, value);
                    sendMessageCompleted = Interlocked.CompareExchange<SendMessageCompletedEventHandler>(ref this._SendMessageCompleted, handler3, handler2);
                }
                while (sendMessageCompleted != handler2);
            }
        }

        public SmsService()
        {
            this.Url = Settings.Default.ChainStock_WebReference_SmsService;
            if (this.IsLocalFileSystemWebService(this.Url))
            {
                this.UseDefaultCredentials = true;
                this.useDefaultCredentialsSetExplicitly = false;
            }
            else
            {
                this.useDefaultCredentialsSetExplicitly = true;
            }
        }

        public void CancelAsync(object userState)
        {
            base.CancelAsync(userState);
        }

        [SoapDocumentMethod("http://tempuri.org/GetBalance", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=SoapBindingUse.Literal, ParameterStyle=SoapParameterStyle.Wrapped)]
        public string GetBalance(int intSmsType, string strSmsSeries, string strSmsSerialPwd)
        {
            return (string) base.Invoke("GetBalance", new object[] { intSmsType, strSmsSeries, strSmsSerialPwd })[0];
        }

        public void GetBalanceAsync(int intSmsType, string strSmsSeries, string strSmsSerialPwd)
        {
            this.GetBalanceAsync(intSmsType, strSmsSeries, strSmsSerialPwd, null);
        }

        public void GetBalanceAsync(int intSmsType, string strSmsSeries, string strSmsSerialPwd, object userState)
        {
            if (this._GetBalanceOperationCompleted == null)
            {
                this._GetBalanceOperationCompleted = new SendOrPostCallback(this.OnGetBalanceOperationCompleted);
            }
            base.InvokeAsync("GetBalance", new object[] { intSmsType, strSmsSeries, strSmsSerialPwd }, this._GetBalanceOperationCompleted, userState);
        }

        private bool IsLocalFileSystemWebService(string url)
        {
            if ((url == null) || (url == string.Empty))
            {
                return false;
            }
            Uri wsUri = new Uri(url);
            return ((wsUri.Port >= 0x400) && (string.Compare(wsUri.Host, "localHost", StringComparison.OrdinalIgnoreCase) == 0));
        }

        private void OnGetBalanceOperationCompleted(object arg)
        {
            if (this._GetBalanceCompleted != null)
            {
                InvokeCompletedEventArgs invokeArgs = (InvokeCompletedEventArgs) arg;
                this._GetBalanceCompleted(this, new GetBalanceCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
            }
        }

        private void OnRegisterExOperationCompleted(object arg)
        {
            if (this._RegisterExCompleted != null)
            {
                InvokeCompletedEventArgs invokeArgs = (InvokeCompletedEventArgs) arg;
                this._RegisterExCompleted(this, new RegisterExCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
            }
        }

        private void OnRegisterZsOperationCompleted(object arg)
        {
            if (this._RegisterZsCompleted != null)
            {
                InvokeCompletedEventArgs invokeArgs = (InvokeCompletedEventArgs) arg;
                this._RegisterZsCompleted(this, new RegisterZsCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
            }
        }

        private void OnSendMessageOperationCompleted(object arg)
        {
            if (this._SendMessageCompleted != null)
            {
                InvokeCompletedEventArgs invokeArgs = (InvokeCompletedEventArgs) arg;
                this._SendMessageCompleted(this, new SendMessageCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
            }
        }

        [SoapDocumentMethod("http://tempuri.org/RegisterEx", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=SoapBindingUse.Literal, ParameterStyle=SoapParameterStyle.Wrapped)]
        public string RegisterEx(string softwareSerialNo, string key, string serialpass)
        {
            return (string) base.Invoke("RegisterEx", new object[] { softwareSerialNo, key, serialpass })[0];
        }

        public void RegisterExAsync(string softwareSerialNo, string key, string serialpass)
        {
            this.RegisterExAsync(softwareSerialNo, key, serialpass, null);
        }

        public void RegisterExAsync(string softwareSerialNo, string key, string serialpass, object userState)
        {
            if (this._RegisterExOperationCompleted == null)
            {
                this._RegisterExOperationCompleted = new SendOrPostCallback(this.OnRegisterExOperationCompleted);
            }
            base.InvokeAsync("RegisterEx", new object[] { softwareSerialNo, key, serialpass }, this._RegisterExOperationCompleted, userState);
        }

        [SoapDocumentMethod("http://tempuri.org/RegisterZs", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=SoapBindingUse.Literal, ParameterStyle=SoapParameterStyle.Wrapped)]
        public string RegisterZs(string sn, string pwd, string province, string city, string trade, string entname, string linkman, string phone, string mobile, string email, string fax, string address, string postcode, string sign)
        {
            return (string) base.Invoke("RegisterZs", new object[] { sn, pwd, province, city, trade, entname, linkman, phone, mobile, email, fax, address, postcode, sign })[0];
        }

        public void RegisterZsAsync(string sn, string pwd, string province, string city, string trade, string entname, string linkman, string phone, string mobile, string email, string fax, string address, string postcode, string sign)
        {
            this.RegisterZsAsync(sn, pwd, province, city, trade, entname, linkman, phone, mobile, email, fax, address, postcode, sign, null);
        }

        public void RegisterZsAsync(string sn, string pwd, string province, string city, string trade, string entname, string linkman, string phone, string mobile, string email, string fax, string address, string postcode, string sign, object userState)
        {
            if (this._RegisterZsOperationCompleted == null)
            {
                this._RegisterZsOperationCompleted = new SendOrPostCallback(this.OnRegisterZsOperationCompleted);
            }
            base.InvokeAsync("RegisterZs", new object[] { sn, pwd, province, city, trade, entname, linkman, phone, mobile, email, fax, address, postcode, sign }, this._RegisterZsOperationCompleted, userState);
        }

        [SoapDocumentMethod("http://tempuri.org/SendMessage", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=SoapBindingUse.Literal, ParameterStyle=SoapParameterStyle.Wrapped)]
        public string SendMessage(int intSmsType, string strSmsSeries, string strSmsSerialPwd, string strSmsMobileList, string strSmsContent, string strSmsTime)
        {
            return (string) base.Invoke("SendMessage", new object[] { intSmsType, strSmsSeries, strSmsSerialPwd, strSmsMobileList, strSmsContent, strSmsTime })[0];
        }

        public void SendMessageAsync(int intSmsType, string strSmsSeries, string strSmsSerialPwd, string strSmsMobileList, string strSmsContent, string strSmsTime)
        {
            this.SendMessageAsync(intSmsType, strSmsSeries, strSmsSerialPwd, strSmsMobileList, strSmsContent, strSmsTime, null);
        }

        public void SendMessageAsync(int intSmsType, string strSmsSeries, string strSmsSerialPwd, string strSmsMobileList, string strSmsContent, string strSmsTime, object userState)
        {
            if (this._SendMessageOperationCompleted == null)
            {
                this._SendMessageOperationCompleted = new SendOrPostCallback(this.OnSendMessageOperationCompleted);
            }
            base.InvokeAsync("SendMessage", new object[] { intSmsType, strSmsSeries, strSmsSerialPwd, strSmsMobileList, strSmsContent, strSmsTime }, this._SendMessageOperationCompleted, userState);
        }

        public string Url
        {
            get
            {
                return base.Url;
            }
            set
            {
                if ((this.IsLocalFileSystemWebService(base.Url) && !this.useDefaultCredentialsSetExplicitly) && !this.IsLocalFileSystemWebService(value))
                {
                    base.UseDefaultCredentials = false;
                }
                base.Url = value;
            }
        }

        public bool UseDefaultCredentials
        {
            get
            {
                return base.UseDefaultCredentials;
            }
            set
            {
                base.UseDefaultCredentials = value;
                this.useDefaultCredentialsSetExplicitly = true;
            }
        }
    }


